import fetch from 'common/src/utils/fetch';
import baseUrl from './env';
import UTILS from "common/src/utils/utils";
import { data } from 'autoprefixer';

/*
    竞赛报名
*/

// 本科生学院专业接口
function getProfessionByFaculty(data) {
    return fetch({
        url:`${baseUrl}/sign/Role/getProfessionByFaculty`,
        method: 'post',
        data
    })
}
// 规则列表
function getList(data) {
    return fetch({
        url: `${baseUrl}/sign/Role/getList`,
        method: 'post',
        data
    })
}
// 启停用
function openOrClose(data) {
    return fetch({
        url: `${baseUrl}/sign/Role/openOrClose`,
        method: 'post',
        data
    })
}
// 删除规则
function deleteRule(data) {
    return fetch({
        url: `${baseUrl}/sign/Role/deleteRule`,
        method: 'post',
        data
    })
}
// 编辑规则
function editRule(data) {
    return fetch({
        url: `${baseUrl}/sign/Role/editRule`,
        method: 'post',
        data
    })
}
// 规则详情
function getRoleById(data) {
    return fetch({
        url: `${baseUrl}/sign/Role/getRoleById?id=` + data,
        method: 'get'
    })
}
// 新增规则
function addRule(data) {
    return fetch({
        url: `${baseUrl}/sign/Role/addRule`,
        method: 'post',
        data
    })
}
// 获取课程信息下拉框
function getCourse(data) {
    return fetch({
        url: `${baseUrl}/sign/Role/getCourse?param=` + data,
        method: 'get'
    })
}
// 成绩列表查询
function getListPage (data) {
    return fetch({
        url: baseUrl + "/sign/scoreManage/listPage",
        method: 'post',
        data
    });
}
// 导出模板(新)
function downTemplate (data) {
  return fetch({
      url: baseUrl + "/sign/scoreManage/downTemplate",
      method: 'get',
      data,
      responseType: 'blob'
  }).then(res => {
      UTILS.downloadFile(res, '下载模板.xlsx', 'application/vnd.ms-excel;charset=utf-8');
  });
}
// 成绩管理(编辑)
function scoreManageEdit (data) {
    return fetch({
        url: baseUrl + "/sign/scoreManage/edit",
        method: 'post',
        data
    });
}
// 单个成绩公共
function publishSingleScore (data) {
    return fetch({
        url: baseUrl + "/sign/scoreManage/publishScore",
        method: 'post',
        data
    });
}
// 批量成绩公共
function batchPublishScore (params) {
    return fetch({
        url: baseUrl + '/sign/scoreManage/batchPublishScore?competitionId=' + params.competitionId + '&releaseStatus=' + params.releaseStatus + '&ids=' + params.ids,
        method: 'get'
    });
}
// 导出列表(成绩管理)
function exportList (data) {
  return fetch({
      url: baseUrl + "/sign/scoreManage/exportList",
      method: 'post',
      data,
      responseType: 'blob'
  }).then(res => {
      UTILS.downloadFile(res, '成绩管理.xlsx', 'application/vnd.ms-excel;charset=utf-8');
  });
}
// 获取已报名人数和已排考人数
function getSignedAndArrangedNum(data) {
    return fetch({
        url: `${baseUrl}/sign/arrange/getSignedAndArrangedNum?competitionId=` + data,
        method: 'get',
    })
}
// 打印准考证 zip
function printExamCard(data) {
    return fetch({
        url: `${baseUrl}/sign/arrange/printExamCard`,
        method: 'post',
        responseType: 'blob',
        data
    }).then(res => {
        UTILS.downloadFile(res, data.printCardType ? '桌标.zip' : '准考证.zip', 'application/zip;charset=utf-8');
    })
}
// 打印考场签到表 zip
function printArriveSheet(data) {
    return fetch({
        url: `${baseUrl}/sign/arrange/printArriveSheet`,
        method: 'post',
        responseType: 'blob',
        data
    }).then(res => {
        UTILS.downloadFile(res, '考场签到表.zip', 'application/zip;charset=utf-8');
    })
}
// 考生信息表 excel
function printStudentInfo(data) {
    return fetch({
        url: `${baseUrl}/sign/arrange/printStudentInfo`,
        method: 'post',
        responseType: 'blob',
        data
    }).then(res => {
        UTILS.downloadFile(res, '考生信息表.xlsx', 'application/vnd.ms-excel;charset=utf-8');
    });
}
// 排考
function arrange(data) {
    return fetch({
        url: `${baseUrl}/sign/arrange/arrange`,
        method: 'post',
        data
    })
}
// 获取转换后的参数(调用获取空闲教室接口前，先调用该接口，获得调用空闲教室接口的入参)
function getReverseCondition(data) {
    return fetch({
        url: `${baseUrl}/sign/arrange/getReverseCondition?competitionId=` + data,
        method: 'get',
    })
}
// 获取每个教室已安排的学生数
function getArrangeClassroomInfo(data) {
    return fetch({
        url: `${baseUrl}/sign/arrange/getArrangeClassroomInfo?competitionId=` + data,
        method: 'get',
    })
}
// 我的成绩(查看列表)
function listPage(data) {
    return fetch({
        url: `${baseUrl}/sign/studentScore/listPage`,
        method: 'post',
        data
    })
}
// 考场下拉
function getClassroomList (param) {
    return fetch({
        url: baseUrl + '/sign/scoreManage/getClassroomList?competitionId=' + param.competitionId,
        method: 'get'
    });
}
// 获取竞赛名称下拉
function getCompetitionNames (data) {
    return fetch({
        url: baseUrl + "/sign/competition/listPage",
        method: 'post',
        data
    });
}
// 报名名单列表
function getSignList (data) {
    return fetch({
        url: baseUrl + "/sign/record/getSignList",
        method: 'post',
        data
    });
}
// 报名名单列表
function selectionFail (data) {
    return fetch({
        url: baseUrl + "/sign/record/selectionFail",
        method: 'post',
        data
    });
}
// 取消不通过
function cancelFail (data) {
    return fetch({
        url: baseUrl + "/sign/record/cancelFail?signStudentId=" + data,
        method: 'get'
        
    });
}
// 选拔完成
function selectComplete (data) {
    return fetch({
        url: baseUrl + "/sign/record/selectComplete",
        method: 'post',
        data
    });
}
// 个人赛导出
function  exportSignUpList (data) {
    return fetch({
        url: baseUrl + "/sign/record/exportSignUpList",
        method: 'post',
        data
    });
}
// 团体赛导出
function exportGroupList (data) {
    return fetch({
        url: baseUrl + "/sign/record/exportGroupList",
        method: 'post',
        data,
        responseType: 'blob'
    }).then(res => {
        UTILS.downloadFile(res, '团体赛报名名单.xls', 'application/vnd.ms-excel;charset=utf-8');
    });
}
// 学生信息列表
function getStudentInfo (data) {
    return fetch({
        url: baseUrl + "/sign/record/getStudentInfo",
        method: 'post',
        data
    });
}
// 代理报名
function agentSignUp (data) {
    return fetch({
        url: baseUrl + "/sign/record/agentSignUp",
        method: 'post',
        data
    });
}
// 人员变更
function personChange (data) {
    return fetch({
        url: baseUrl + "/sign/record/personChange",
        method: 'post',
        data
    });
}
// 教学班下拉
function getTeachingClass (data) {
    return fetch({
        url: "/api/arrangementservice/manualArrange/page2",
        method: 'post',
        data
    });
}
// 获取团体赛人员信息
function getGroupInfo(data) {
    return fetch({
        url: `${baseUrl}/sign/record/getGroupInfo?id=` + data,
        method: 'get'
    })
}
// 下载导入不通过名单 模板
function downloadTemplate(data) {
    return fetch({
        url: `${baseUrl}/sign/record/importFailTemplate`,
        method: 'get',
        responseType: 'blob'
      }).then(res => {
        UTILS.downloadFile(res, '导入不通过名单.xlsx', 'application/vnd.ms-excel;charset=utf-8');
      });
}
export default {
    getList: getList,
    openOrClose: openOrClose,
    deleteRule: deleteRule,
    editRule: editRule,
    getRoleById: getRoleById,
    addRule: addRule,
    getCourse: getCourse,
    getListPage: getListPage,
    downTemplate: downTemplate,
    scoreManageEdit: scoreManageEdit,
    publishSingleScore: publishSingleScore,
    batchPublishScore: batchPublishScore,
    exportList: exportList,
    getSignedAndArrangedNum: getSignedAndArrangedNum,
    printExamCard: printExamCard,
    printArriveSheet: printArriveSheet,
    printStudentInfo: printStudentInfo,
    arrange: arrange,
    getReverseCondition: getReverseCondition,
    getArrangeClassroomInfo: getArrangeClassroomInfo,
    listPage: listPage,
    getClassroomList: getClassroomList,
    getCompetitionNames: getCompetitionNames,
    getSignList: getSignList,
    selectionFail: selectionFail,
    selectComplete: selectComplete,
    exportSignUpList: exportSignUpList,
    exportGroupList: exportGroupList,
    getStudentInfo: getStudentInfo,
    agentSignUp: agentSignUp,
    getTeachingClass: getTeachingClass,
    getGroupInfo: getGroupInfo,
    personChange: personChange,
    getProfessionByFaculty: getProfessionByFaculty,
    cancelFail: cancelFail,
    downloadTemplate
};
